package model

import (
	"gorm.io/gorm"
	"shop/database/mysql"
)

// 商品属性表
type GoodsProperty struct {
	gorm.Model
	Name    string `gorm:"column:name;type:varchar(255)" json:"name"`
	GoodsId int64  `gorm:"column:goods_id;type:int(11)" json:"goods_id"`
}

func (g *GoodsProperty) GoodsPropertyById(goodsId int) (goods []*GoodsProperty, err error) {
	return goods, mysql.WithMysql(func(db *gorm.DB) error {
		return db.Model(g).Where("goods_id = ?", goodsId).Find(&goods).Error
	})
}
